🎄 Christmas Word Guessing Game 🎄

We created this activity using ChatGPT, an AI tool. We've given it a quick test but it still might not work correctly. If it doesn't quite work, try to fix it!

Welcome! In this project, you’ll create a fun Christmas-themed word guessing game using Python. You’ll guess letters to figure out the secret word before you run out of attempts. Let’s get started!

Step 1: Define the Word List

We’ll begin by creating a list of Christmas-themed words. This will be the source for the secret word the player has to guess. Launch a code editor like Thonny, and add this code:

words = ["snowman", "reindeer", "presents", "stocking", "holly", "carols", "chimney", "sleigh"]

What does this do?

🎉 Great start! You’ve created the word list. Let’s pick a word from it next!

Step 2: Randomly Select a Word

We’ll use Python’s random library to pick a word from the list. Add this code:

import random secret_word = random.choice(words)

What does this do?

✨ Well done! The game now picks a secret word. Let’s set up the guesses next!

Step 3: Add Emojis

Let’s make the game festive by including emojis! You don't have to do this, but if you want, you can copy emojis directly into Thonny or use your keyboard shortcut:

Update your game introduction like this:

print("🎄 Welcome to the Christmas Word Guessing Game! 🎄") print("Guess the Christmas word letter by letter.") print("You have 6 wrong attempts. Let's begin!")

🎁 Awesome! Your game now looks festive and fun. Let’s continue!

Step 4: Set Up the Guesses

We’ll prepare to track the player’s guesses by starting with blank spaces. Add this code:

word_length = len(secret_word) guesses = ["_"] * word_length attempts = 6

What does this do?

🎶 Fantastic! You’ve set up the blanks and allowed guesses. Time to build the game loop!

Step 5: Create the Game Loop

We’ll create a loop that lets the player guess letters until they win or run out of attempts. Add this code:

while attempts > 0: print("\nCurrent word: " + " ".join(guesses)) print(f"Attempts remaining: {attempts}") guess = input("Enter a letter: ").lower() if len(guess) != 1 or not guess.isalpha(): print("❌ Invalid input. Please enter a single letter.") continue if guess in secret_word: print("✅ Correct!") for i in range(word_length): if secret_word[i] == guess: guesses[i] = guess else: print("❌ Wrong guess!") attempts -= 1 if "_" not in guesses: print("\n🎉 Congratulations! You've guessed the word: " + secret_word) break else: print("\n😢 Out of attempts! The word was: " + secret_word)

What does this do?

🌟 Amazing! You’ve created the game loop. Now let’s test the game!

Step 6: Run and Test the Game

Save your code as word_guess.py and run it in Thonny. Play the game by guessing letters. Here are some things to try:

🎉 Congratulations! You’ve built a fully functional word guessing game. Great work!